import type { IEditCouponData } from "@/api/modules/marketingTool"


export interface ICurrencyItem {
  id: number;
  name: string;
}

/**
 * 商城列表的ITEM
 */
export interface IMallPageItem {
  id: number;
  mallName: string;
  currencyId: number;
  payConfigId: null | null;
}

/**
 * 创建商城的form表单
 */
export interface ICreateMallData {
  currencyId: number | null;
  mallName: string;
  payType: string;
  payConfigId: string;
  externalMemberConfigId: string;
  loginType: "sms" | "external";
  externalLoginConfigId: number | null;
  loginStyleId: number;
  loginStyleIdSel: number;
  externalSmsConfigId: number;
  externalSmsConfigIdSel: number;
}

/**
 * 商品管理列表 查询
 */
export interface IGoodsPageData {
  mallId: number;
  onlineStatus: number | null;
  currentPage: number;
  showCount: number;
  withProducts: boolean;
  queryInsIds?: number[];
  categoryId?: number | null;
  type?: number | null;
  name?: string | null;
  prePrice?: number | null;
  aftPrice?: number | null;
  sort?: number | null;
  sortType?: 1 | 2;
  storeId?: number | null;
  goodsType: string | null
}

/**
 * 商品管理列表ITEM
 */
export interface IGoodsPageRow {
  id: number;
  storeGoodsId: number;
  detailText: string;
  name: string;
  onlineStatus: number;
  beforeStock: number;
  thumbnailUrl: string;
  showMinCurrencyPrice: number;
  showMinPrice: number;
  priceRange: string;
  productsLoading?: boolean;
  products?: IStoreProductRow[];
  type?: string;
  stock?: number;
  packNum?: number;
}

export interface IMerchantCategoryOption {
  id: number;
  categoryName: string;
}
export interface IStoreGoodsPageDataOption {
  defaultStore: number;
}
/**
 * 商品选择器 查询PARAM
 */
export interface IStoreGoodsPageData {
  mallId: number,
  showCount: number;
  currentPage: number;
  defaultStore: number;
  name?: string | null;
  categoryId?: number | null;
  storeIds?: number[] | string[] | undefined;
  minCost:string|number|null;
  maxCost:string|number|null;
}

/**
 * 商品选择器 表格单项
 */
export interface IStoreGoodsPageRow {
  storeProductId: number;
  productName: string;
  stock: number;
  currentStock: number;
  productLimit: number;
  productCategory: number;
  mallProductCategory: number;
  amount: number;
  id: number;
  name: string;
  products?: IStoreProductRow[];
  status?: 1 | 0;
  thumbnailUrl?: string;
  detailText?: string;
  description?: string;
  type?: string;
  storeId?: number;
  storeName?: string;
}

/**
 * 编辑商品 中的规格行, 编辑规格中的规格行
 */
export interface IStoreProductRow {
  id: number;
  storeProductId: number | null;
  name: string;
  thumbnailUrl: string;
  payOfCurrencyCount: number;
  originalPrice: number;
  payPrice: number;
  stock: number;
  totalStock: number;
  beforeStock: number;
  addOrDeductionStockCount: number; // 库存差值
  onlineStatus: 0 | 1;
  goodsId: number;
  storeGoodsId?: number;
  mallId?: number;
  enableMemberPrice?: number;
  memberPriceList?: IMemberPriceItem[];
  payOfCurrencyId?: number;
  costPrice: number;
  exchangeRatio?: number | string
}

export interface IMemberPriceItem {
  memberId: number;
  payOfCurrencyCount: number;
  payPrice: number;
  onlyMembersCanBuy: number;
}

/**
 * 新增商品 响应payload 和 保存提交form
 */
export interface IStoreGoodsDetail {
  mallId: number;
  storeGoodsId: number | undefined;
  id: number | undefined;
  name: string | undefined;
  categoryId: number | undefined;
  showCurrencyNames: string | undefined;
  showMinPrice: number | undefined;
  // showMaxPrice: string,
  showMinCurrencyPrice: number | undefined;
  // showMaxCurrencyPrice: string,
  limitTimeType: string;
  productLimit: number | undefined;
  thumbnailUrl: string | undefined | string[];
  description: string | undefined;
  detailText: string | undefined;
  products: IStoreProductRow[];
  stock: number;
  sort: number;
  originalPrice: any;
  onlineStatus: number | null;
  bannerImages: undefined | string | string[];
  rechargeAccountRegexId?: number;
  rechargePlaceHolder?: string;
  rechargeAccountRegex?: string
}

/**
 * 保存添加商品 APIdata
 */
export interface IStoreAddGoodsData {
  productEntities: IStoreGoodsPageRow[];
}

/**
 * 商品管理 - 编辑商品 - formdata
 */
export interface IUpdateProductData {
  name: string | undefined;
  categoryId: number | null;
  thumbnailUrl: string | null;
  productLimit: number | null;
  description: string | undefined;
  detailText: string | undefined;
  enableMemberPrice: number;
  memberPriceList: IVipItem[];
}

/**
 * 编辑会员
 */
export interface IVipItem {
  memberName: string;
  onlyMembersCanBuy: number;
  payOfCurrencyCount: number | undefined;
  payPrice: number | undefined;
  memberId: number;
}

/**
 * 商品列表 数量统计
 */
export interface IGoodsStatic {
  totalAmount: number | undefined;
  onlineAmount: number | undefined;
  offlineAmount: number | undefined;
}

/**
 * 商品分类ITEM
 */
export interface IGoodsCateItem {
  id: number;
  name: string; // 分类名
  status: number;
}

/**
 * 编辑修改分类
 */
export interface ISaveUpdateCategoryData {
  mallId: number;
  name: string;
  sort: number;
  status: number;
  img: string;
  remark: string;
}

/**
 * 供应商ITEM
 */
export interface ISupplierItem {
  id: number;
  storeName: string;
}

/**
 * 订单查询data
 */
export interface IOrderPageData {
  orderNum: string;
  phone: string;
  startTime: number | null;
  endTime: number | null;
  productName: string;
  type: number | null; // 商品类型
}

/**
 * 订单列表ITEM
 */
export interface IOrderPageRow {
  id: number;
}

/**
 * 订单详情查询参数
 */
export interface IOrderDetailData {
  id: string;
  businessId?: string;
  businessType?: string;
}

/**
 * 订单详情
 */
export interface IOrderDetail {
  id: number;
  createTime: number | null;
  payTime: number | null;
  verifyStep: number | null;
  auditTime: number | null;
  goodsType: string;
  storeShipTime: number | null;
  ext: {
    storeShipTime: number | null
  } | null;
  finishTime: number | null;
  pickUpTime: number | null;
  status: number;
  user: {
    unionId: number | null;
  } | null;
  errMsg: string | null;
  externalRequestRecordBos: IExternalRequestRecordBosItem[] | null;
}

/**
 * 订单详情供应商日志
 */
export interface IExternalRequestRecordBosItem {
  createTime: number | null;
  callbackStatus: number | null;
  status: number | null;
}

/**
 * 异常订单查询参数
 */
export interface IAbnormalDetailData {
  id: string;
}

/**
 * 异常订单详情
 */
export interface IAbnormalOrderDetail {
  orderNo: string;
  status: string;
  errMsg: string | null;
  thumbnailUrl: string | null;
  exception: {
    status: string| null;
    userReason: string | null;
    userDescription: string | null;
    userImages: string | null;
    storeName: string | null;
    storeProcessTime: number | null;
    storeDescription: string | null;
    userLogisticsCompany: string | null;
    userLogisticsNum: string | null;
  } | null;
  user: {
    unionId: string | null;
  } | null;
}

/**
 * 订单计数列表项
 */
export interface IOrderStatisticsItem {
  count: number;
  status: string;
  verifyStep: string | null;
}

export interface IAfterSaleOrderPageData {
  id: string;
  orderNo: string;
  unionId: string;
  status: string;
  userPhone: string;
  queryCreateTimeStart: string;
  queryCreateTimeEnd: string;
  queryInsIds: number[];
  businessType: string;
  businessId: number;
}

/**
 * 页面列表查询data
 */
export interface IMallPageData {
  relationId: number;
  name: string;
  insId: string;
  currentPage?: number;
  showCount?: number;
}

/**
 * 页面列表单项 ITEM
 */
export interface IMallPageListRow {
  id: number | any;
  name: string;
  pageLink: string;
  canonicalPageLink: string;
}

/**
 * 省市区接口的接口参数
 */
export interface IDeliverData {
  id: number;
  provinceCode?: string;
}

/**
 * 省市区 单项
 */
export interface IDeliverItem {
  id: number;
  provinceCode?: string;
  cityCode?: string;
  provinceName?: string;
  cityName?: string;
  children?: IDeliverItem[];
  exist: 0 | 1 | 2; // 0 未选择 1 选择子项全部 2 选择子项部分
  parent?: IDeliverItem;
}

/**
 * 现有省市区配置
 */
export interface IDeliverConfig {
  strCode: string[] | null;
}

export interface IOrderConfig {
  deliverTimeout: number | null;
  orderTimeout: number | null;
  serviceTimeout: number | null;
}

export interface MallConfig {
  deliverTimeout: number | null;
  orderTimeout: number | null;
  serviceTimeout: number | null;
  mallName: string | null;
  payConfigId: string | null;
  payType: string | null;
  discount: string | null;
  mallPageSettings: string | null;
  mallCode: string | null;
  loginType: "sms" | "external";
  loginStyleId: number;
  externalSmsConfigId: number;
  externalLoginConfigId: number | null;
  loginStyleIdSel: number | null;
  externalSmsConfigIdSel: number | null;
}

export interface IOrderConfigData extends IOrderConfig {
  mallId: number;
}

export interface IPaginationData {
  showCount: number;
  currentPage: number;
}

export interface ISaveVipPriceData {
  enableMemberPrice: number;
  id: string;
  memberPriceList: IVipItem[];
}

/**
 * 商城优惠券管理 优惠券行数据
 */
export interface ICouponManageRow {
  id: number;
  status: number;
}

/**
 * 商城优惠券管理 批次行数据
 */
export interface ICouponManageBatchRow {
  id: number;
}

/**
 * 商城新增或编辑 相关的优惠券详情
 */
export interface IMallCouponDefineInfo extends IEditCouponData {}
